package org.apache.flink.runtime.resourceprovider.exceptions;

import org.apache.flink.api.common.ConsumerID;
import org.apache.flink.runtime.clusterframework.types.AllocationID;
import org.apache.flink.util.Preconditions;

/** Exception which signals that a slot is already occupied by the given {@link AllocationID}. */
public class SlotOccupiedException extends SlotAllocationException {
    private static final long serialVersionUID = -3986333914244338888L;

    private final AllocationID allocationId;

    private final ConsumerID jobId;

    public SlotOccupiedException(String message, AllocationID allocationId, ConsumerID jobId) {
        super(message);
        this.allocationId = Preconditions.checkNotNull(allocationId);
        this.jobId = Preconditions.checkNotNull(jobId);
    }

    public AllocationID getAllocationId() {
        return allocationId;
    }

    public ConsumerID getJobId() {
        return jobId;
    }
}
